/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.giant.entities;

import com.giant.entities.pos.PInvoicePayment;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author david
 */
@Entity
@Table(name = "payment_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PaymentType.findAll", query = "SELECT p FROM PaymentType p"),
    @NamedQuery(name = "PaymentType.findByIdPaymentType", query = "SELECT p FROM PaymentType p WHERE p.idPaymentType = :idPaymentType"),
    @NamedQuery(name = "PaymentType.findByDescription", query = "SELECT p FROM PaymentType p WHERE p.description = :description"),
    @NamedQuery(name = "PaymentType.findByStatus", query = "SELECT p FROM PaymentType p WHERE p.status = :status")})
public class PaymentType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_payment_type")
    private Integer idPaymentType;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "status")
    private boolean status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPaymentType")
    private Collection<PInvoicePayment> pInvoicePaymentCollection;

    public PaymentType() {
    }

    public PaymentType(Integer idPaymentType) {
        this.idPaymentType = idPaymentType;
    }

    public PaymentType(Integer idPaymentType, String description, boolean status) {
        this.idPaymentType = idPaymentType;
        this.description = description;
        this.status = status;
    }

    public Integer getIdPaymentType() {
        return idPaymentType;
    }

    public void setIdPaymentType(Integer idPaymentType) {
        this.idPaymentType = idPaymentType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    @XmlTransient
    public Collection<PInvoicePayment> getPInvoicePaymentCollection() {
        return pInvoicePaymentCollection;
    }

    public void setPInvoicePaymentCollection(Collection<PInvoicePayment> pInvoicePaymentCollection) {
        this.pInvoicePaymentCollection = pInvoicePaymentCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPaymentType != null ? idPaymentType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PaymentType)) {
            return false;
        }
        PaymentType other = (PaymentType) object;
        if ((this.idPaymentType == null && other.idPaymentType != null) || (this.idPaymentType != null && !this.idPaymentType.equals(other.idPaymentType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.giant.entities.PaymentType[ idPaymentType=" + idPaymentType + " ]";
    }
    
}
